home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
madtrb29.arc
/
TURBLE.LBR
/
HEXDEMO.PQS
/
hexdemo.pas
Wrap
Pascal/Delphi Source File
|
1985-03-03
|
5KB
|
171 lines
{$I turble.pas}
{$i GetPut.pas}
{$i Paint.pas}
var
Ch : Char;
Hexagon : Storage;
Got, Drawn, Long, Erase, GetPut : Boolean;
I, DistV, DistH, Resolute, Intersect, Color, Palet : Integer;
DistS, ResoluteS, EraseS, IntersectS, ProgS : String[12];
Procedure Default; {Set defaults. }
begin
Long := True;
Resolute := 5;
Erase := False;
Intersect := 3;
Palet := 0;
Color := 1;
end;
Procedure Drawit; {Draw the hexagon. }
begin
Pencolor(none);
Moveto(CenterX + 1, CenterY - 4);
Pencolor(Color);
for I := 1 to 6 do
begin
Poly(3,20);
Turn(60);
end;
Case Resolute of {Paint the appropriate sections. }
4: begin
paint(StartX + 5,StartY,Color,1);
paint(StartX - 5,StartY,Color,1);
paint(StartX + 2,StartY - 10,Color,2);
paint(StartX - 2,StartY + 10,Color,2);
end;
5: begin
paint(StartX + 5,StartY,Color,1);
paint(StartX - 2,StartY - 10,Color,2);
paint(StartX - 2,StartY + 10,Color,3);
end;
6: begin
paint(StartX + 3,StartY - 10,Color,1);
paint(StartX - 10,StartY,Color,1);
paint(StartX + 3,StartY + 10,Color,1);
end;
end; {Case}
end;
Procedure MoveIt; {Move the hexagon. }
begin
If not Got then
begin
Get(CenterX-16,CenterY-24,32,40,Hexagon,'');
If Erase then Put(Hexagon,CenterX - 16,CenterY-24,b,'');
Got := True;
end;
Put(Hexagon,CenterX + DistH,CenterY - 24 + DistV,Intersect,'');
end;
Procedure SetEmUp; {Set all the parameters. }
begin
If Long then {Parameter for Distance. }
begin
Randomize;
DistV := Random(100);
Randomize;
DistH := Random(120);
If Odd(Random(2)) then DistH := -DistH;
If Resolute = 6 then
begin
DistH := DistH * 2;
DistV := DistV * 2;
end;
DistS := 'Long';
end
else
begin
DistS := 'Short';
DistV := 0;
DistH := 0;
end;
Case Resolute of {Parameter for Resolution. }
4 : ResoluteS := 'Medium';
5 : ResoluteS := 'Medium Color';
6 : ResoluteS := 'High';
end; {Case}
If Erase then EraseS := 'On' else EraseS := 'Off'; {Flag for Erase. }
Case Intersect of {Parameter for Intersect. }
1 : IntersectS := 'AND';
2 : IntersectS := 'OR';
3 : IntersectS := 'XOR';
4 : IntersectS := 'NOT';
5 : IntersectS := 'EQU';
end; {Case}
end;
Procedure Menu; {Print menu. }
begin
Mode(Resolute);
Palettor(Palet);
PenColor(Color);
Writeln('Distance (D) ',DistS);
writeln('Mode (M) ',ResoluteS);
writeln('Erase (E) ',EraseS);
writeln('Intersect (I) ',IntersectS);
writeln('Palette (P) Palette ',Palet);
writeln('Pencolor (C) Color ',Color);
writeln('Go (G)');
writeln('Quit (Q)');
Drawn := False;
Got := False;
end;
Procedure Choose; {Choose parameters. }
begin
read(kbd,ch);
Case UpCase(ch) of
'D' : If Long then Long := False else Long := True;
'M' : begin
Color := 1;
If Resolute = 5 then Palet := 15 else Palet := 0;
If Resolute = 6 then Resolute := 4 else Resolute := Resolute + 1;
end;
'E' : If Erase then Erase := False else Erase := True;
'I' : begin
If Intersect > 5 then Intersect := Intersect - 5;
If Intersect = 5 then Intersect := 1
else Intersect := Intersect + 1;
end;
'P' : Case Resolute of
4 : If Palet >= 1 then Palet := 0 else Palet := 1;
5 : If Palet >= 3 then Palet := 0 else Palet := Palet + 1;
6 : If Palet >= 15 then Palet := 1 else Palet := Palet + 1;
end;
'C' : Case Resolute of
4, 5 : If Color = 3 then Color := 1 else Color := Color + 1;
6 : Color := 1;
end; {Case}
'G' : begin
If not Drawn then
begin
DrawIt;
Drawn := True;
end;
MoveIt;
end;
end; {Case}
While UpCase(Ch) <> 'Q' do
begin
SetEmUp; {Set parameters. }
If UpCase(Ch) <> 'G' then Menu; {Print menu. }
Choose; {Choose parameters -- recursive.}
end;
end;
begin
Default;
SetEmUp;
Menu;
Choose; {Most work done in one recursive procedure.}
ClrScr;
end.